@using k8s.Models
@using BlazorApp.Pages.Common.Html.HTable
@inherits BlazorApp.Pages.Common.DrawerPageBase<V1Node>
<Divider Orientation="left" Style="font-weight:bold">@L["Capacity"]</Divider>
<HTable>
    <HTr>
        <HTh>@L["Type"]</HTh>
        <HTh>@L["Capacity"]</HTh>
        <HTh>@L["Allocatable"]</HTh>
    </HTr>
    <HTr>
        <HTd>@L["Pods"]</HTd>
        <HTd>@Echo("pods", Capacity)</HTd>
        <HTd>@Echo("pods", Allocatable)</HTd>
    </HTr>
    <HTr>
        <HTd>@L["CPU"]</HTd>
        <HTd>@Echo("cpu", Capacity)</HTd>
        <HTd>@Echo("cpu", Allocatable)</HTd>
    </HTr>
    <HTr>
        <HTd>@L["Memory"]</HTd>
        <HTd>@Echo("memory", Capacity)</HTd>
        <HTd>@Echo("memory", Allocatable)</HTd>
    </HTr>
    <HTr>
        <HTd>@L["Ephemeral Storage"]</HTd>
        <HTd>@Echo("ephemeral-storage", Capacity)</HTd>
        <HTd>@Echo("ephemeral-storage", Allocatable)</HTd>
    </HTr>
    <HTr>
        <HTd>@L["Hugepages"]-1Gi</HTd>
        <HTd>@Echo("hugepages-1Gi", Capacity)</HTd>
        <HTd>@Echo("hugepages-1Gi", Allocatable)</HTd>
    </HTr>
    <HTr>
        <HTd>@L["Hugepages"]-2Mi</HTd>
        <HTd>@Echo("hugepages-2Mi", Capacity)</HTd>
        <HTd>@Echo("hugepages-2Mi", Allocatable)</HTd>
    </HTr>
</HTable>

@code {

    [Parameter]
    public IDictionary<string, ResourceQuantity> Capacity { get; set; }

    [Parameter]
    public IDictionary<string, ResourceQuantity> Allocatable { get; set; }


    private string Echo(string key, IDictionary<string, ResourceQuantity> dict)
    {
        return dict.FirstOrDefault(w => w.Key == key).Value
            ?.CanonicalizeString();
    }

}
